package campus.controller;

import campus.model.Account;
import campus.model.AccountExample;
import campus.service.AccountService;
import campus.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author VULCAN
 * @create 2020-05-08 0:18
 * @desc 账套控制层
 **/
@RestController
@CrossOrigin
@RequestMapping("account")
public class AccountController {
    @Autowired
    private AccountService accountService;

    /**
      * @name  账套列表
     * @Author VULCAN
     * @Date 2020/5/8 1:10
     */
    @RequestMapping(value = "/selectByExample",method = RequestMethod.GET)
    public List<Account> selectByExample(AccountExample example) {
        return accountService.selectByExample(null);
    }

    /**
      * @name  账套分页
     * @Author VULCAN
     * @Date 2020/5/8 1:10
     */
    @RequestMapping(value = "findByAllPageSize/{pageNum}/{pageSize}",method = RequestMethod.POST)
    public PageResult findByAllPageSize(@RequestBody Account account, @PathVariable("pageNum") int pageNum , @PathVariable("pageSize") int pageSize){
        PageResult findallpage = accountService.findByAllPageSize(account,pageNum, pageSize);
        return findallpage;
    }
    /**
      * @name  账套添加
     * @Author VULCAN
     * @Date 2020/5/8 1:10
     */
    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    public int insert(@RequestBody Account record) {
        return accountService.insert(record);
    }

    /**
      * @name  账套主键删除
     * @Author VULCAN
     * @Date 2020/5/8 1:10
     */
    @RequestMapping(value = "/delete/{ztId}",method = RequestMethod.DELETE)
    public int deleteByPrimaryKey(@PathVariable(value = "ztId") Integer ztId) {
        return accountService.deleteByPrimaryKey(ztId);
    }

    /**
      * @name  账套修改
     * @Author VULCAN
     * @Date 2020/5/8 1:10
     */
    @RequestMapping(value = "/accountupdate",method = RequestMethod.POST)
    public int updateByPrimaryKeySelective(@RequestBody Account record) {
        return accountService.updateByPrimaryKeySelective(record);
    }

    /**
      * @name  主键id
     * @Author VULCAN
     * @Date 2020/5/8 1:09
     */
    @RequestMapping(value = "/findByPrimaryKey/{ztId}",method = RequestMethod.GET)
    public Account findByPrimaryKey(@PathVariable(value = "ztId") Integer ztId) {
        return accountService.findByPrimaryKey(ztId);
    }
}
